<?php

/**
 * Created by PhpStorm.
 * User: chenzhitao
 * Date: 2018/1/24
 * Time: 上午9:49
 */
namespace App\Busi\Modules;
use App\Http\Result\Result;

interface BusiInterface
{

    /**
     * Serv 通用响应方法
     *
     * @return Result
     */
    public function response();

}

class BaseBusi implements BusiInterface
{
    /**
     * @var Result
     */
    protected $result = null;

    /**
     * 每页展示数量
     * @var int
     */
    protected $page_num = 20;

    /**
     * BaseServ constructor.
     *
     * @param array|null $handleParams
     * @param Result $result
     */
    public function __construct(array $handleParams = [], Result $result)
    {
        $this->result = $result;
        $data = app()->call([$this, 'handle'], $handleParams);
        if ($data instanceof Result) {
            $this->result = $data;
        } else if (!is_null($data)) {
            $this->result->setData($data);
        }
    }

    /**
     * @param Result $result
     */
    public function setResult(Result $result)
    {
        $this->result = $result;
    }

    /**
     * BaseServ 通用响应方法
     * @return Result
     */
    public function response()
    {
        return $this->result;
    }


}